package talkplace;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedList;

public class mail {
public String getTime() {
		return time;
	}
	public void setTime(String time) {
		this.time = time;
	}
	public String getInput() {
		return input;
	}
	public void setInput(String input) {
		this.input = input;
	}
	public String getUndo() {
		return undo;
	}
	public void setUndo(String undo) {
		this.undo = undo;
	}
public int getRequest() {
		return request;
	}
	public void setRequest(int request) {
		this.request = request;
	}
	public int getPlace() {
		return place;
	}
	public void setPlace(int place) {
		this.place = place;
	}
@Override
	public String toString() {
		return request+" "+place;
	}

private int request;
private int place;
private String time;
private String input;
private String undo;
mail(int request,int place ){
	this.request=request;
	this.place=place;

}
mail(int request,int place,Date date,String input){
	
	this.request=request;
	this.place=place;
	this.time=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date);
	this.input=input;
	
}
mail(int request,int place,Date date){
	this.request=request;
	this.place=place;
	this.time=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date);
}
mail(String st){
	String []s=st.split(" ");
	this.request=Integer.valueOf(s[0]);
	this.place=Integer.valueOf(s[1]);
	if(s.length>2)
		{StringBuilder sb=new StringBuilder();
		for(int i=2;i<s.length;i++)sb.append(s[i]+" ");
		this.undo=sb.toString();
		}
}
	public String put(int id,ArrayList<man>listman) {
		StringBuilder sb=new StringBuilder();
	sb.append(id+" ");
	listman.forEach(i->{
		if(i!=null&&i.place!=-1)
		sb.append(i.getPlace()+" ");});
	//	System.out.println(sb.toString());
		return sb.toString();
	}
	public String integrate(String []st) {
		StringBuilder sb=new StringBuilder();
		
		for(int i=1;i<st.length;i++)
		
			sb.append("port:"+st[i]+"\n");
		
		return sb.toString();
	}
	public String[] re() {
		String[]st=new String[2];
		String[]temp=this.undo.split(" ");
		StringBuilder sb=new StringBuilder();
		sb.append(temp[0]+" ").append(temp[1]);
		st[0]=sb.toString();
		sb.delete(0, sb.length());
		for(int i=2;i<temp.length;i++)sb.append(this.place+":"+temp[i]+" ");
		st[1]=sb.toString();
		return st;
		
	}
	public String reArea() {
		return this.request+" "+this.place+" "+this.time;
	}
	public String textinput() {
		return request+" "+place+" "+time+" "+input;
	}	

	
}
